home *** CD-ROM | disk | FTP | other *** search
- ;-------------------------hex16out routine begins--------------------------+
- ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
- ; page : 55
- ;
- ; NAME HEX16OUT
- ; ROUTINE FOR Conversion from 16-bit Binary to ASCII Hexidecimal
- ;
- ; FUNCTION: This routine accepts a 16-bit binary number in the DX register
- ; and converts it to ASCII hexidecimal form which is sent to the std input
- ; device.
- ;
- ; INPUT: Upon entry an 16-bit binary number is in DX
- ; OUTPUT: A string of ASCII digits representing a hexidecimal number is
- ; sent out through the std output device.
- ; REGISTERS USED: No registers are modified. DX is used for input.
- ; SEGMENTS REFERENCED: None
- ; ROUTINES CALLED: STDOUT
- ; SPECIAL NOTES: None
- ;
- ; ROUTINE TO CONVERT FROM INTERNAL 16-BIT BINARY TO ASCII HEXIDECIMAL.
- ;
- hex16out proc far
- ;
- ; a binary number is in DX
- ;
- push cx ; save registers
- push ax
- ;
- mov cx,4 ; loop for a count of four
- ;
- hex16out1:
- push cx ; save the count
- mov cl,4 ; for a count of four
- rol dx,cl ; rotate DX left
- ;
- mov al,dl ; move into AL
- and al,00Fh ; just digit
- daa ; add 6 if A - F
- add al,0F0h ; bump a carry if A - F
- adc al,040h ; here is the ASCII
- call stdout ; send it
- ;
- pop cx
- loop hex16out1
- ;
- pop ax ; restore registers
- pop cx
- ret ; return
- ;
- hex16out endp
- ;-------------------------hex16out routine ends---------------------------+